/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package nx.behaviors;

import nx.utils.*;
/**
 *
 * @author alejo
 */
public class NxPSDetectVanishPoint extends NxBehavior {

    VPSocketStream conn;

    //the size of the image.
    //TODO: EStos parametros deberian ser pedidos por protocolo a la aplicacion
    //C/C++
    private int imgWidth;
    private int imgHeight;

    private int msgNum;
    private int vpX;
    private int vpY;
    private int vpFid;


    public NxPSDetectVanishPoint(String name, int imgWidth, int imgHeight, String ipAddr, int port)
    {
        super(name);

        this.imgWidth = imgWidth;
        this.imgHeight = imgHeight;
        conn = new VPSocketStream(ipAddr,port);
    }

    public int getVpX()
    {
        return this.vpX;
    }

    public int getVpY()
    {
        return this.vpY;
    }

    public int getVpFid()
    {
        return this.vpFid;
    }


    public int getWidth()
    {
        return this.imgWidth;
    }

    public int getHeight()
    {
        return this.imgHeight;
    }

    public int getMsgNum()
    {
        return this.msgNum;
    }
    
    
    public Vector2D Value()
    {
        try
        {
            conn.readObject();
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }

        this.msgNum = conn.getMsgNum();
        this.vpX = conn.getX();
        this.vpY = conn.getY();
        this.vpFid = conn.getFidelity();

        return new Vector2D(vpX,vpY,Vector2D.MODE_XY);

    }
}
